package com.lc.app.androidfirst.userdefine.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.text.AttributedCharacterIterator;

/**
 * Created by LC on 12/6/2015.
 */
public class MyButton extends Button {
    public static int count = 0;

    public MyButton(Context context,AttributeSet set) {
        super(context, set);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        super.onKeyDown(keyCode, event);
        Toast.makeText(getContext(),"Click CallBack",Toast.LENGTH_SHORT).show();
        Log.i("Tag", "Click Call Back Button");
        return true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        super.onTouchEvent(event);
        if(count == 0){
            Toast.makeText(getContext(),"Click CallBack Touch.",Toast.LENGTH_SHORT).show();
            count ++ ;
        }
        return true;
    }
}
